1/**
 * 用户档案里面项目列表
 */

function person_off_info(){
    var _this = this;
    var page;
    _this.page_size = 10;

    _this.init = function(page_person){
        page = page_person;
        _this.initTable();
    };

    _this.initTable = function(){
        var list_url = appPath + "/admin/dossier/person/project_off_list";
        page.init("off_person_info_form", list_url, "off_person_info_table", "off_person_info_page", 1, _this.page_size);
        page.goPage(1);
        page.list = function(dataList){console.log(dataList)
            var len = dataList.length;
            var inner = "", item;
            // 组装数据
            for(var i=0; i< len; i++) {
                item = dataList[i];
                inner += '<tr>';
                inner += '<td>' + (i+1) + '</td>';
                inner += '<td data-length="20" title="' + item['project_name'] + '"><span class="tooltip">'+ item['project_name'] + '</span></td>';
                inner += '<td>'+ TimeUtil.longMsTimeConvertToDateTime(item['project_start_time']) + '<br/>' + TimeUtil.longMsTimeConvertToDateTime(item['project_end_time']) + '</td>';
                inner += '<td>'+ TimeUtil.getHouAndMinAndSec(item['studyTime']) + '</td>';
                inner += '<td>'+ item['score'] + '</td>';
                var isPassed = item['isPassed'];
                if(isPassed == 1){
                    inner += '<td>合格</td>';
                }else if(isPassed == 2){
                    inner += '<td>不合格</td>';
                }else{
                    inner += '<td>-</td>';
                }
                inner += '<td>';
                inner += '<a  onclick="person_off_info.projectOffInfo(\'' + item['id']  + '\');" class="a a-info">详情</a>';
                inner += '<a href="javascript:void(0);" onclick="person_off_info.processRecord(\'' + item['id'] + '\');" class="a a-view">过程记录</a>';
                inner += '</td>';
                inner += '</tr>';
            }
            return inner;
        }
    };

    _this.search_off = function(){
        _this.initTable();
    };

    _this.searchAll_off = function(){
        $("#off_person_info_form").find("input[name=off_project_name]").val("");
        $("#off_person_info_form").find("input[name=off_project_start_time]").val("");
        $("#off_person_info_form").find("input[name=off_project_end_time]").val("");
        _this.initTable();
    };


    _this.ajax = function(url, param, type) {
        var result;
        $.ajax({
            url : url,
            async : false,
            type : 'post',
            data : param,
            success : function(data) {
                result = data;
            }
        });
        return result;
    };

    // 项目自定义排序
    _this.sort_off = function (value, obj) {
        $("#off_sortBy").val(value);
        var order = obj.className
        if(order == 'sort asc'){
            $("#off_descAsc").val('DESC')
        }else{
            $("#off_descAsc").val('ASC')
        }
        // 刷新列表
        _this.initTable();
    }

    //查看线下项目详情
    _this.projectOffInfo = function(projectId) {
        window.location.href=appPath+"/admin/dossier/person/projectOffInfo?projectId="+projectId;
    }
    //查看过程记录
    _this.processRecord = function(projectId) {
        window.location.href=appPath+"/admin/dossier/person/processRecord?projectId="+projectId+"&userId="+$("#user_id").val();
    }
}

var person_off_info = new person_off_info();